//
//  UIBarButtonItem + extension.swift
//  weibo001
//
//  Created by CL on 16/7/9.
//  Copyright © 2016年 CL. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    //定义导航栏按钮的便利构造函数
    convenience init(title: String, target:AnyObject?, action: Selector) {
        //调用其他指定函数
        self.init()
        let button  = UIButton()
        button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
        button.setTitle(title, forState: .Normal)
        
        //设置文字颜色
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        
        //设置字体大小
        button.titleLabel?.font = UIFont.systemFontOfSize(15)
        
        //设置大小
        button.sizeToFit()
        
        //设置自定义视图
       customView = button
        
   
        
    }
    
    
    
    
}
